<style include="cr-hidden-style cr-icons realbox-dropdown-shared-style">
  :host {
    display: block;
    outline: none;
  }

  #action {
    margin-inline-start: 40px; /* icon width + text padding */
  }

  .container {
    align-items: center;
    cursor: default;
    display: flex;
    overflow: hidden;
    padding-bottom: 6px;
    padding-inline-end: 16px;
    padding-inline-start: 12px;
    padding-top: 6px;
    position: relative;
  }

  .container + .container {
    padding-bottom: 12px;
    padding-top: 0;
  }

  #contents,
  #description {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #ellipsis {
    inset-inline-end: 0;
    position: absolute;
  }

  #focus-indicator {
    background-color: var(--google-blue-600);
    border-radius: 3px;
    display: none;
    height: 100%;
    margin-inline-start: -15px; /* -1 * (.container padding + width / 2) */
    position: absolute;
    width: 6px;
  }

  /* TODO(crbug.com/1430996): Add focus indicator for secondary results. */
  :host(:is(:focus-visible, [selected]:not(:focus-within)):not(
      [side-type-class_='secondary-side'])) #focus-indicator {
    display: block;
  }

  #prefix {
    opacity: 0;
  }

  #separator {
    white-space: pre;
  }

  #tail-suggest-prefix {
     position: relative;
  }

  #text-container {
    align-items: center;
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    padding-inline-end: 8px;
    padding-inline-start: 8px;
    white-space: nowrap;
  }

  :host([is-rich-suggestion]) #text-container {
    align-items: flex-start;
    flex-direction: column;
  }

  :host([is-rich-suggestion]) #separator {
    display: none;
  }

  :host([is-rich-suggestion]) #contents,
  :host([is-rich-suggestion]) #description {
    width: 100%;
  }

  /* Deemphasizes description for entities with images. */
  :host([is-entity-suggestion][has-image]) #description {
    font-size: .875em;
  }

  .match {
    font-weight: 600;
  }

  /* Uses a dimmed color for description for entities. */
  :host([is-entity-suggestion]) #description,
  .dim {
    color: var(--color-realbox-results-foreground-dimmed);
  }

  /* Uses a dimmed color for description for entities. */
  :host-context(cr-realbox-match:-webkit-any(:focus-within, [selected])):host([is-entity-suggestion]) #description,
  :host-context(cr-realbox-match:-webkit-any(:focus-within, [selected])) .dim {
    color: var(--color-realbox-results-dim-selected);
  }

  .url {
    color: var(--color-realbox-results-url);
  }

  :host-context(cr-realbox-match:-webkit-any(:focus-within, [selected])) .url {
    color: var(--color-realbox-results-url-selected);
  }

  #remove {
    margin-inline-end: 1px;
    opacity: 0; /* Hides the button while keeping it in tab order. */
  }

  :host-context(cr-realbox-match:hover) #remove {
    opacity: 1;
  }

  :host-context(cr-realbox-match:-webkit-any(:focus-within, [selected])) #remove {
    --cr-icon-button-fill-color:
        var(--color-realbox-results-icon-selected);
    opacity: 1;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image]) {
    border-radius: 16px;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      .container {
    box-sizing: border-box;
    flex-direction: column;
    padding: 6px;
    padding-block-end: 16px;
    width: 102px;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      .focus-indicator {
    display: none;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #icon {
    --cr-realbox-icon-border-radius: 12px;
    /* Disable placeholder dominant color as the images are large and the
     * placeholder color looks like a flash of unstyled content. */
    --cr-realbox-icon-container-bg-color: transparent;
    height: 90px;
    margin-block-end: 8px;
    width: 90px;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #text-container {
    padding: 0;
    white-space: normal;
    width: 100%;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #contents,
  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #description {
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    font-weight: 400;
    overflow: hidden;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #contents {
    font-size: 13px;
    line-height: 20px;
    margin-block-end: 4px;
  }

  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #description {
    font-size: 12px;
    line-height: 16px;
  }


  :host([side-type-class_='secondary-side'][is-entity-suggestion][has-image])
      #remove {
    display: none;
  }
</style>
<div class="container" aria-hidden="true">
  <div id="focus-indicator"></div>
  <cr-realbox-icon id="icon" match="[[match]]"></cr-realbox-icon>
  <div id="text-container">
    <span id="tail-suggest-prefix" hidden$="[[!tailSuggestPrefix_]]">
      <span id="prefix">[[tailSuggestPrefix_]]</span>
      <!-- This is equivalent to AutocompleteMatch::kEllipsis which is
           prepended to the match content in other surfaces-->
      <span id="ellipsis">...&nbsp</span>
    </span>
    <span id="contents" inner-h-t-m-l="[[contentsHtml_]]"></span>
    <span id="separator" class="dim">[[separatorText_]]</span>
    <span id="description" inner-h-t-m-l="[[descriptionHtml_]]"></span>
  </div>
  <cr-icon-button id="remove" class="action-icon icon-clear"
    aria-label="[[removeButtonAriaLabel_]]"
    on-click="onRemoveButtonClick_" on-mousedown="onRemoveButtonMouseDown_"
    title="[[removeButtonTitle_]]" hidden$="[[!match.supportsDeletion]]"
    tabindex="2">
  </cr-icon-button>
</div>
<template is="dom-if" if="[[actionIsVisible_]]">
  <div class="container" aria-hidden="true">
    <cr-realbox-action id="action" action="[[match.action]]"
                     tabindex="1" on-click="onActionClick_"
                     on-keydown="onActionKeyDown_">
    </cr-realbox-action>
  </div>
</template>
